// MapWidget.h - MapWidget class
// Implements the A* pathfinding algorithm and
// the widget for displaying the algorithm

#ifndef MAPWIDGET_H
#define MAPWIDGET_H
#include <QWidget>
#include <QStringList>
#include <QPixmap>
#include "Node.h"
#include "Parser.h"

namespace Ui {
class MapWidget;
}

class MapWidget : public QWidget
{
    Q_OBJECT
    
public:
    explicit MapWidget(QWidget *parent = 0);
    ~MapWidget();

    void buildMap(QString, QString);
    bool setPoints(QString, QString, QString);
    void printNodes(void);

    void runAStar(void);
    QStringList getNodeNames(void);

    void drawPoints(void);
    void drawConnections(void);

    void clearMap(void);

signals:
    void displayPath(QString);
    void sendMessage(QString);
    void pause(void);

public slots:
    void newNode(Node*, int);
    void searchFinished(bool);
    void threadReturned(void);
    void pauseThread(void);

protected:
    void paintEvent(QPaintEvent*);
    
private:
    void printPathHome(void);

    void drawPathToStart(Node*);
    void drawExploredPoint(Node*, int);

    Ui::MapWidget *ui;

    Node* startNodePtr;
    Node* destinationNodePtr;
    Node* excludedNodePtr;
    NodeMap* nodeMapPtr;

    QPixmap pointsPixmap;
    QPixmap connectionsPixmap;
    QPixmap astarPixmap;

    bool searchFinishedStatus;

};

#endif // MAPWIDGET_H
